package org.gruposp2p.proyectokarma.gwt.client.ui.tag;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import org.gruposp2p.proyectokarma.gwt.client.MainEntryPoint;
import org.gruposp2p.proyectokarma.gwt.client.event.EventBusManager;
import org.gruposp2p.proyectokarma.gwt.client.event.TagEvent;

public class TagPanel extends Composite implements TagEvent.Handler {

	private static SearchVoteUiBinder uiBinder = GWT.create(SearchVoteUiBinder.class);
	interface SearchVoteUiBinder extends UiBinder<Widget, TagPanel> { }

	@UiField VerticalPanel mainPanel;
	@UiField VerticalPanel bodyPanel;
    @UiField HTML title;
	
	
	public TagPanel() {
		initWidget(uiBinder.createAndBindUi(this));
		EventBusManager.getInstance().registerToTagEvent(this);
        sinkEvents(Event.ONLOAD);
        sinkEvents(Event.ONCLICK); 
	}


	@Override
	public void onTagChanged(TagEvent event) {
		switch (event.eventAction) {
			case GET_DOCUMENTS:
				title.setHTML(
						MainEntryPoint.INSTANCE.constants.titleMessage(event.tagName));
				break;
		}
		
	}
	
    public void onBrowserEvent(Event event) {
    	Log.debug("Paaaagina caaaaaaaaaargada");
    }
    

}